# Makefile2.6

TARGET = btrfs_bmap
OBJECT = super.o ctree.o extent-tree.o print-tree.o root-tree.o dir-item.o \
	   file-item.o inode-item.o inode-map.o disk-io.o \
	   transaction.o inode.o file.o tree-defrag.o \
	   extent_map.o sysfs.o struct-funcs.o xattr.o ordered-data.o \
	   extent_io.o volumes.o async-thread.o ioctl.o locking.o orphan.o \
	   export.o tree-log.o acl.o free-space-cache.o zlib.o \
	   compression.o delayed-ref.o relocation.o

ifneq ($(KERNELRELEASE),)

#kbuild syntax.
obj-m += $(TARGET).o
$(TARGET)-objs :=  $(OBJECT)

else

PWD := $(shell pwd)
KERNEL_DIR := /lib/modules/`uname -r`/build

all : modules

modules:
	$(MAKE) -C $(KERNEL_DIR) M=$(PWD) modules

install:
	install ./$(TARGET).ko /usr/local/lib

uninstall:
	rm -f /usr/local/lib/$(TARGET).ko

insmod:
	modprobe libcrc32c zlib_deflate
	insmod $(TARGET).ko
	
rmmod:
	rmmod $(TARGET)

clean:
	rm -rf .*.cmd *.o *.mod.c *.ko .tmp_versions

endif